<script setup>
import { appScTransferCountUnsigned } from "@/services/transfer";
import topNav from "../../components/topNav.vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { nextTick, ref, watch, onMounted, onUnmounted } from "vue";
const showSelect = ref("");

if (uni.getStorageSync("selectShopType")) {
  showSelect.value = uni.getStorageSync("selectShopType");
}

onLoad((e) => {});

onShow(() => {
  getappScTransferCountUnsigned();
});
onUnmounted(() => {});

const saveFun = () => {};

const toNav = (url) => {
  uni.navigateTo({
    url: url,
  });
};

const totallObj = ref({});

const getappScTransferCountUnsigned = async () => {
  let res = await appScTransferCountUnsigned({});
  totallObj.value = res.data;
};
</script>

<template>
  <view class="bg">
    <topNav :title="'调货'" @save="saveFun" rType="save"></topNav>
    <!-- <up-navbar
      bgColor="#ffffff"
      @rightClick="rightClick"
      :autoBack="true"
      :safeAreaInsetTop="true"
      :fixed="true"
      :placeholder="true"
      :leftText="'返回'"
    >
      <template #right> </template>
      <template #center>
        <text
          class="text-white"
          style="
            font-weight: 500;
            font-size: 34rpx;
            color: #000000;
            line-height: 48rpx;
            text-align: center;
          "
          >支付状态</text
        ></template
      >
    </up-navbar> -->

    <view class="select" v-if="showSelect == 'admin'">
      <view
        v-permission="['manager:scTransfer:create']"
        class="select-item"
        @click="toNav('/pages/transfer/homein/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/1.png" mode="scaleToFill" />
            <text>新建调货单</text></view
          >
          <view class="select-item-left-value">库存店铺调货、库存数量编辑</view>
        </view>
        <view class="select-item-right">
          <up-icon
            name="plus"
            color="#FF5722"
            size="46rpx"
            :bold="true"
          ></up-icon>
        </view>
      </view>
      <view
        class="select-item"
        v-permission="['manager:scTransfer:source']"
        @click="toNav('/pages/transfer/record/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/2.png" mode="scaleToFill" />
            <text>调货记录</text></view
          >
          <view class="select-item-left-value"
            >调货人信息、调货店铺、调货商品</view
          >
        </view>
      </view>

      <view
        v-permission="['manager:scTransfer:return:query']"
        class="select-item"
        @click="toNav('/pages/transfer/return_list/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/3.png" mode="scaleToFill" />
            <text>调货退货</text></view
          >
          <view class="select-item-left-value">调货单调货退货、提醒签收</view>
        </view>
      </view>
      <view
        v-permission="['manager:scTransfer:target']"
        class="select-item"
        @click="toNav('/pages/transfer/sign/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/4.png" mode="scaleToFill" />
            <text class="title"
              >调货签收
              <view class="box">
                <up-badge
                  numberType="overflow"
                  :type="'error'"
                  :value="totallObj.count || 0"
                ></up-badge>
              </view>
            </text>
          </view>
          <view class="select-item-left-value">调货状态待处理、待查看</view>
        </view>
      </view>
    </view>

    <view class="select" v-if="showSelect == 'shop'">
      <view class="select-item" @click="toNav('/pages/transfer/homein/index')">
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/1.png" mode="scaleToFill" />
            <text>新建调货单</text></view
          >
          <view class="select-item-left-value">库存店铺调货、库存数量编辑</view>
        </view>
        <view class="select-item-right">
          <up-icon
            name="plus"
            color="#FF5722"
            size="46rpx"
            :bold="true"
          ></up-icon>
        </view>
      </view>
      <view class="select-item" @click="toNav('/pages/transfer/record/index')">
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/2.png" mode="scaleToFill" />
            <text>调货记录</text></view
          >
          <view class="select-item-left-value"
            >调货人信息、调货店铺、调货商品</view
          >
        </view>
      </view>

      <view
        class="select-item"
        @click="toNav('/pages/transfer/return_list/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/3.png" mode="scaleToFill" />
            <text>调货退货</text></view
          >
          <view class="select-item-left-value">调货单调货退货、提醒签收</view>
        </view>
      </view>
      <view class="select-item" @click="toNav('/pages/transfer/sign/index')">
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/4.png" mode="scaleToFill" />
            <text class="title"
              >调货签收
              <view class="box">
                <up-badge
                  numberType="overflow"
                  :type="'error'"
                  :value="totallObj.count || 0"
                ></up-badge>
              </view>
            </text>
          </view>
          <view class="select-item-left-value">调货状态待处理、待查看</view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
@import "index.scss";
</style>
